<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      th:replace="~{admin/layout :: html(title=${title}, content=~{::content})}">
<head>
    <title>公告管理</title>
</head>
<body>
<div th:fragment="content">
    <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>

    <a href="/admin/announcement/add" class="btn btn-primary mb-3"><i class="fas fa-plus"></i> 添加新公告</a>

    <table class="table table-striped">
        <thead>
        <tr>
            <th>ID</th>
            <th>标题</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="announcement : ${announcementList}">
            <td th:text="${announcement.id}"></td>
            <td th:text="${#strings.abbreviate(announcement.title, 50)}"></td>
            <td th:text="${#temporals.format(announcement.createTime, 'yyyy-MM-dd')}"></td>
            <td>
                <a th:href="@{/admin/announcement/edit/{id}(id=${announcement.id})}" class="btn btn-sm btn-warning"><i class="fas fa-edit"></i></a>
                <a th:href="@{/admin/announcement/delete/{id}(id=${announcement.id})}" class="btn btn-sm btn-danger"
                   onclick="return confirm('确定要删除这条公告吗？');"><i class="fas fa-trash"></i></a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
</body>
</html> 